/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.item.etcitem.action;

import com.lineage.server.PacketCreate;
import com.lineage.server.model.L1PcInventory;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.item.ItemExecutor;

/**
 * Class <code>ScrollSeal</code> 封印卷轴 - 41426.
 * 
 * @author jrwz
 * @version 2012-6-19下午01:09:08
 * @see com.lineage.server.model.item.etcitem.action
 * @since JDK1.7
 */
public final class ScrollSeal extends ItemExecutor {

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static ItemExecutor get() {
        return new ScrollSeal();
    }

    /** 封印卷轴 - 41426. */
    private ScrollSeal() {
    }

    @Override
    public void execute(final L1PcInstance pc, final L1ItemInstance useItem,
            final int readC1, final int readC2, final int targetId,
            final int targetX, final int targetY) {
        final int itemobj = targetId;
        final L1ItemInstance lockItem = pc.getInventory().getItem(itemobj);

        if (lockItem == null) {
            return;
        }

        if (((lockItem != null) && (lockItem.getItem().getType2() == 1))
                || (lockItem.getItem().getType2() == 2)
                || ((lockItem.getItem().getType2() == 0) && lockItem.getItem()
                        .isCanSeal())) {
            if ((lockItem.getBless() == 0) || (lockItem.getBless() == 1)
                    || (lockItem.getBless() == 2) || (lockItem.getBless() == 3)) {
                int bless = 1;
                switch (lockItem.getBless()) {
                    case 0:
                        bless = 128;
                        break;
                    case 1:
                        bless = 129;
                        break;
                    case 2:
                        bless = 130;
                        break;
                    case 3:
                        bless = 131;
                        break;
                }
                lockItem.setBless(bless);
                pc.getInventory().updateItem(lockItem, L1PcInventory.COL_BLESS);
                pc.getInventory().saveItem(lockItem, L1PcInventory.COL_BLESS);
                pc.getInventory().removeItem(useItem, 1);
            } else {
                PacketCreate.get().sendSinglePackets(pc, "没有任何事情发生");
            }
        } else {
            PacketCreate.get().sendSinglePackets(pc, "没有任何事情发生");
        }
    }
}
